package com.etc.dao.impl;

import com.etc.dao.OrderCountDao;
import com.etc.entity.OrderCount;
import com.etc.util.DBUtil;
import com.etc.util.PageData;

import java.util.List;

public class OrderCountDaoImpl implements OrderCountDao {

    @Override
    public List<OrderCount> getOrderCount() {
        //SELECT DATE_FORMAT(orderdate,'%Y-%m-%d') AS cdays,count(orderid) AS countFROM tbl_order WHERE date(orderdate)> DATE_SUB(CURDATE(),INTERVAL 6 DAY) GROUP BY cdays ORDER BY cdays
        String sql = "SELECT DATE_FORMAT(orderdate,'%Y-%m-%d') AS cdays,count(orderid) AS count FROM tbl_order WHERE date(orderdate)> DATE_SUB(CURDATE(),INTERVAL 6 DAY) GROUP BY cdays ORDER BY cdays";
        return DBUtil.exQuery(sql, OrderCount.class);
    }
}
